package com.atguigu.spzx.manager.mapper;

import com.atguigu.spzx.manager.entity.ProductSku;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <p>
 * ProductSkuMapper
 * </p>
 *
 * @author flyduck
 * @since 2023/11/2
 */
@Mapper
public interface ProductSkuMapper extends BaseMapper<ProductSku> {
    /**
     * 根据productId查询
     * @param productId
     * @return
     */
    default List<ProductSku> getByProductId(Long productId) {
        QueryWrapper<ProductSku> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id", productId);
        return this.selectList(queryWrapper);
    }

    /**
     * 根据productId删除
     * @param productId
     */
    default void deleteProductSkuByProductId(Long productId) {
        QueryWrapper<ProductSku> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id", productId);
        this.delete(queryWrapper);
    }
}
